﻿// -----------------------------------------------------------------------
// <copyright file="IBookService.cs" company="EPAM Systems">
////Copyright (c) EPAM Systems, 2012. All rights reserved.
// </copyright>
// -----------------------------------------------------------------------

namespace MBOP.Core.Interfaces.Services
{
	#region Usings

	using System;
	using System.Collections.Generic;

	using MBOP.Core.Entities.Library;
	using MBOP.Core.FilterContexts;

	#endregion

	/// <summary>
	/// Provides the common interface of the book operations.
	/// </summary>
	public interface IBookService
	{
		#region Methods

		/// <summary>
		/// Adds the book to library
		/// </summary>
		/// <param name="book">The book.</param>
		void AddBook(Book book);

		/// <summary>
		/// Deletes the book from library
		/// </summary>
		/// <param name="bookID">The book id.</param>
		void DeleteBook(int bookID);

		/// <summary>
		/// Updates the book in library
		/// </summary>
		/// <param name="book">The book.</param>
		void UpdateBook(Book book);

		/// <summary>
		/// Gets the count of books in library by the specific filter context.
		/// </summary>
		/// <param name="filterContext">The book filter context.</param>
		/// <returns>The count of elements in the sequence.</returns>
		int GetBookCount(BookFilterContext filterContext);

		/// <summary>
		/// Get books from library.
		/// </summary>
		/// <param name="skipCount">The number of skipping books.</param>
		/// <param name="takeCount">The number of taking books.</param>
		/// <param name="filterContext">The book filter context.</param>
		/// <param name="sortInfo">The sort info</param>
		/// <returns>The books collection</returns>
		IEnumerable<Book> GetBooks(int skipCount, int takeCount, BookFilterContext filterContext, SortInfo sortInfo);

		/// <summary>
		/// Gets the book from library by id.
		/// </summary>
		/// <param name="bookID">The book id.</param>
		/// <returns>The book.</returns>
		Book GetBookByID(int bookID);

		/// <summary>
		/// Checks that the current book is available for reading or not.
		/// </summary>
		/// <param name="book">The current book.</param>
		/// <returns>The result of operation.</returns>
		bool IsAvailableForReading(Book book);

		/// <summary>
		/// Adds the subscription to book in library.
		/// </summary>
		/// <param name="bookSubscription">The book subscription.</param>
		void AddSubscription(BookSubscription bookSubscription);

		/// <summary>
		/// Rolls current subscription forward or back in history.
		/// </summary>
		/// <param name="currentSubscription">The current person subscription.</param>
		/// <param name="isUndo">The value indicates the current operation is undo or redo.</param>
		void RollSubscription(BookSubscription currentSubscription, bool isUndo);

		/// <summary>
		/// Deletes all person subscription from book in library.
		/// </summary>
		/// <param name="subscriptionSet">The subscription set.</param>
		/// <param name="bookID">The book id.</param>
		void DeletePersonSubscriptions(string subscriptionSet, int bookID);

		/// <summary>
		/// Gets the current person subscription.
		/// </summary>
		/// <param name="book">The book.</param>
		/// <param name="personID">The person's id.</param>
		/// <param name="subscriptionSet">The subscription set</param>
		/// <returns>The book subscription.</returns>
		BookSubscription GetCurrentPersonSubscription(Book book, string personID, string subscriptionSet);

		/// <summary>
		/// Gets the current person subscription
		/// </summary>
		/// <param name="book">THe current book.</param>
		/// <param name="subscriptionFromBook">Any person subscription for book where to find.</param>
		/// <returns>The current person subscription.</returns>
		BookSubscription GetCurrentPersonSubscription(Book book, BookSubscription subscriptionFromBook);

		/// <summary>
		/// Gets the person state time.
		/// </summary>
		/// <param name="book">The current book.</param>
		/// <param name="personID">The person's id.</param>
		/// <param name="subscriptionSet">The subscription set.</param>
		/// <returns>The person state time.</returns>
		TimeSpan GetPersonTime(Book book, string personID, string subscriptionSet);

		/// <summary>
		/// Gets the person id by subscription set.
		/// </summary>
		/// <param name="bookID">The book id</param>
		/// <param name="subscriptionSet">The subscription set.</param>
		/// <returns>The person's id.</returns>
		string GetPersonIDBySet(int bookID, string subscriptionSet);

		/// <summary>
		/// Gets the current reader.
		/// </summary>
		/// <param name="book">The book.</param>
		/// <returns>The book subscription.</returns>
		BookSubscription GetReader(Book book);

		/// <summary>
		/// Gets the book's history list.
		/// </summary>
		/// <param name="book">The book.</param>
		/// <returns>The book subscriptions collection.</returns>
		IEnumerable<BookSubscription> GetHistoryList(Book book);

		/// <summary>
		/// Gets the book's waiting list.
		/// </summary>
		/// <param name="book">The book.</param>
		/// <returns>The book subscriptions collection</returns>
		IEnumerable<BookSubscription> GetWaitingList(Book book);

		/// <summary>
		/// Checks the current person with specified identity is already in waiting list or not.
		/// </summary>
		/// <param name="book">The book.</param>
		/// <param name="personID">The person's id.</param>
		/// <returns>The result of checking operation.</returns>
		bool IsInWaitingList(Book book, string personID);

		/// <summary>
		/// Checks the current person with specified indentity is already  in history list or not.
		/// </summary>
		/// <param name="book">The book.</param>
		/// <param name="personID">The person's id.</param>
		/// <returns>The result of checking operation.</returns>
		bool IsInHistoryList(Book book, string personID);

		/// <summary>
		/// Indicates that the current person can be added into the waiting list or not.
		/// </summary>
		/// <param name="book">The current book.</param>
		/// <param name="personID">The person's id.</param>
		/// <returns>The result of the checking operation.</returns>
		bool CanAddInWaitingList(Book book, string personID);

		#endregion
	}
}
